package com.satoken.controller;

import cn.dev33.satoken.annotation.SaCheckLogin;
import cn.dev33.satoken.annotation.SaCheckPermission;
import cn.dev33.satoken.annotation.SaCheckRole;
import cn.dev33.satoken.session.SaSessionCustomUtil;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/user")
public class UserSaCheckConrtroller {

    @SaCheckLogin
    @RequestMapping("/info")
    public String info(){
        return "查询用户信息 登录后可以查看";
    }


    @SaCheckRole("qqq")
    @SaCheckPermission("user.add")
    @RequestMapping("/add")
    public String add(){
        return "必须具有指定才能进入该方法 ";
    }

    @RequestMapping("/isExists")
    public String isExists(){
       return String.valueOf(SaSessionCustomUtil.isExists("username"));
    }

    @RequestMapping("/getSessionById")
    public String getSessionById(){
        SaSessionCustomUtil.getSessionById("password").set("password","123456");
        return String.valueOf(SaSessionCustomUtil.isExists("password"));
    }
}
